package com.cloud.punish.workflow.handler.common;

import org.apache.commons.lang.StringUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;

import com.cloud.punish.workflow.command.WfRequest;
import com.cloud.punish.workflow.command.WfResponse;
import com.cloud.punish.workflow.handler.AfterHandler;

/**
 * SQL后置执行器
 * @author taominglong
 *
 */
public class SqlExecutorAfterHandler extends AfterHandler {
	private String sql;

	public SqlExecutorAfterHandler(String sql) {
		super();
		this.sql = sql;
	}

	@Override
	public void afterHandler(WfRequest request, WfResponse resp, ApplicationContext context) {
		if(!StringUtils.isEmpty(sql)){
			JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);
			jdbcTemplate.execute(sql);
		}
	}

}
